// pages/service/index.js
const util = require('../../utils/util.js');
const apiUrl = require('../../utils/apiUrl.js');
var http = require('../../utils/httpHelper.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    isVideoShow: false,
    isHYShow: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.doCheck();
  },
  onShow: function () {
    var that = this;
    var isCheck = wx.getStorageSync("isCheck");
    that.setData({
      isVideoShow: !isCheck,
    });
    
    var user = wx.getStorageSync("user");
    if (user) {
      var group_id = user.group_id;

      if (group_id&&group_id.indexOf(19) >= 0) {
        that.setData({
          isHYShow: true,
        });
      }
    }
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.doCheck();
  },
  doCheck: function () {
    var that = this;
    var user = wx.getStorageSync("user");
    var uid = 0;
    if (user) {
      uid = user.id;
    }
    //获取用户信息
    http.ApiGet(apiUrl.UrlCheck, {"uid":uid}, function (res) {
      wx.stopPullDownRefresh(); //停止下拉刷新
      wx.hideNavigationBarLoading(); //完成停止加载
      if (res.code == 1) {
        wx.setStorageSync("isCheck", true);
      } else {
        wx.setStorageSync("isCheck", false);
      }
      that.onShow();
    });
  },
  btnTap: function (e) {
    var index = e.currentTarget.dataset.index;
    console.log(index);
    if(index==1){
      //文章
      wx.navigateTo({
        url: '../news/index'
      })
    }else if(index==2){
      //动态
      wx.navigateTo({
        url: '../dt/index'
      })
    }else if(index==3){
      //视频
      wx.navigateTo({
        url: '../video/index'
      })
    }else if(index==4){
      //微视
      wx.navigateTo({
        url: '../ws/index'
      })
    }else if(index==5){
      //问答
      wx.navigateTo({
        url: '../wd/index'
      })
    }else if(index==6){
      //社团管理
      wx.navigateTo({
        url: '../organization/index'
      })
    }else if(index==7){
      //社团会员等级
      wx.navigateTo({
        url: '../level/index'
      })
    }else if(index==8){
      //社团会员管理
      wx.navigateTo({
        url: '../member/index'
      })
    }else if(index==9){
      //社团会员通知管理
      wx.navigateTo({
        url: '../member/notice'
      })
    }else{

    }
   
  },
  onShareAppMessage: function () {
    // 用户点击右上角分享
    return {
      title: '同心云会员系统', // 分享标题
      desc: '', // 分享描述
      path: '/pages/login/index' // 分享路径
    }
  }
})